package com.cn.zmc.design.strategy;

public class StrategyPattern {

    public static void main(String[] args) {
        new StrategyFactory().strategy(2).strategy();
    }

    public static interface StrategyService {

        void strategy();

    }

    public static class MethodA implements StrategyService{


        @Override
        public void strategy() {
            System.out.println("MethodA");
        }
    }

    public static class MethodB implements StrategyService{


        @Override
        public void strategy() {
            System.out.println("MethodB");
        }
    }

    public static class MethodC implements StrategyService{


        @Override
        public void strategy() {
            System.out.println("MethodC");
        }
    }


    public static class StrategyFactory{

        public StrategyService strategy(int type) {
            if (type == 1) {
                return new MethodA();
            } else if (type == 2) {
                return new MethodB();
            } else {
                return new MethodC();
            }
        }
    }
}
